package psn.hui.sys.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import psn.hui.sys.constant.SysConstant;
import psn.hui.sys.service.LogInfoService;
import psn.hui.sys.utils.DataGridView;
import psn.hui.sys.utils.JsonResult;
import psn.hui.sys.vo.LogInfoVo;

/**
 * 	登录日志控制器
 * @author hui
 *
 */
@RestController
@RequestMapping("logInfo")
public class LogInfoController {
	@Autowired
	private LogInfoService logInfoService;
	
	/**
	 * 条件查询登录日志
	 * @param logInfoVo
	 * @return
	 */
	@RequestMapping("logInfoList")
	public DataGridView logInfoList(LogInfoVo logInfoVo) {
		return logInfoService.queryAllLogInfo(logInfoVo);
	}
	/**
	 * 	根据id删除登录日志
	 * @param id
	 * @return
	 */
	@RequestMapping("deleteById")
	public JsonResult deleteById(Integer id) {
		try {
			if(logInfoService.deleteById(id) > 0) {
				return SysConstant.DELETE_SUCCESS;
			}
		}catch(Exception e) {
			e.printStackTrace();
		}
		return SysConstant.DELETE_ERROR;
	}
	/**
	 * 	根据id批量删除登录日志
	 * @param logInfoVo
	 * @return
	 */
	@RequestMapping("batchDeleteLogInfoByIds")
	public JsonResult batchDeleteLogInfoByIds(LogInfoVo logInfoVo) {
		try {
			if(logInfoService.batchDeleteLogInfoByIds(logInfoVo.getIds()) > 0) {
				return SysConstant.DELETE_SUCCESS;
			}
		}catch(Exception e) {
			e.printStackTrace();
		}
		return SysConstant.DELETE_ERROR;
	}
	
}
